﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:local="clr-namespace:Ocean.OceanFramework.WPF">
    <Style TargetType="{x:Type local:FormNotification}">
        <Style.Resources>
            <local:StringLengthToBooleanConverter x:Key="stringLengthToBooleanConverter" />
        </Style.Resources>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FormNotification}">
                    <Grid Width="Auto" Height="Auto" Background="{Binding Path=Background, RelativeSource={RelativeSource TemplatedParent}}">
                        <Canvas x:Name="canvasEntryErrors" HorizontalAlignment="Stretch" Visibility="Collapsed">
                            <Expander x:Name="PART_Expander" Foreground="{Binding Path=ErrorHeaderForeground, RelativeSource={RelativeSource TemplatedParent}}" Header="{Binding Path=ErrorHeaderText, RelativeSource={RelativeSource TemplatedParent}}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <Grid Background="{x:Null}" />
                            </Expander>
                        </Canvas>
                        <TextBlock Text="{Binding Path=NotificationMessage, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{Binding Path=NotificationMessageForeground, RelativeSource={RelativeSource TemplatedParent}}" Background="{Binding Path=NotificationMessageBackground, RelativeSource={RelativeSource TemplatedParent}}" Margin="5,5,5,5" TextWrapping="Wrap" x:Name="txtNofificationMessage" VerticalAlignment="Center" Visibility="Collapsed" HorizontalAlignment="Stretch" /> 
            
                        <TextBlock Text="{Binding Path=WatermarkMessage, RelativeSource={RelativeSource TemplatedParent}}" Foreground="{Binding Path=WatermarkMessageForeground, RelativeSource={RelativeSource TemplatedParent}}" Background="{Binding Path=WatermarkMessageBackground, RelativeSource={RelativeSource TemplatedParent}}" Margin="5,5,5,5" TextWrapping="Wrap" x:Name="txtWatermarkMessage" Visibility="Visible" HorizontalAlignment="Stretch" FontStyle="Italic" /> 
            
     	            </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="NotificationMessage" Value="" />
                                <Condition Property="ErrorMessage" Value="" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.Setters>
                                <Setter Property="Visibility" Value="Visible" TargetName="txtWatermarkMessage" />
                                <Setter Property="Visibility" Value="Collapsed" TargetName="txtNofificationMessage" />
                                <Setter Property="Visibility" Value="Collapsed" TargetName="canvasEntryErrors" />
                            </MultiTrigger.Setters>
                        </MultiTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding Path=ErrorMessage, RelativeSource={RelativeSource Self}, Converter={StaticResource stringLengthToBooleanConverter}}" Value="False" />
                                <Condition Binding="{Binding Path=NotificationMessage, RelativeSource={RelativeSource Self}, Converter={StaticResource stringLengthToBooleanConverter}}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <MultiDataTrigger.Setters>
                                <Setter Property="Visibility" Value="Collapsed" TargetName="txtWatermarkMessage" />
                                <Setter Property="Visibility" Value="Visible" TargetName="txtNofificationMessage" />
                                <Setter Property="Visibility" Value="Collapsed" TargetName="canvasEntryErrors" />
                            </MultiDataTrigger.Setters>
                        </MultiDataTrigger>
                        <MultiDataTrigger>
                            <MultiDataTrigger.Conditions>
                                <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Converter={StaticResource stringLengthToBooleanConverter}, Path=ErrorMessage}" Value="True" />
                            </MultiDataTrigger.Conditions>
                            <MultiDataTrigger.Setters>
                                <Setter Property="Visibility" Value="Collapsed" TargetName="txtWatermarkMessage" />
                                <Setter Property="Visibility" Value="Collapsed" TargetName="txtNofificationMessage" />
                                <Setter Property="Visibility" Value="Visible" TargetName="canvasEntryErrors" />
                            </MultiDataTrigger.Setters>
                        </MultiDataTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
